<template>
	<view class="setting_container pt_8">
		<view class="cell" v-for="item,index in list" :key="index" @click="handleClick(item)">
			<view class="cell_content">
				<text>{{item.name}}</text>
				<view class="fx aic jce">
					<text class="mr_4">{{item.value}}</text>
					<u-icon name="arrow-right" color="#333333" size="32rpx"></u-icon>
				</view>
			</view>
		</view>
		<view class="ml_16 mr_16" style="margin-top: 280rpx;">
			<button class="custom_btn w100 bc_fff fc_primary fz_16 lh_44 br_85" @click="handleLogout">退出登录</button>
		</view>
	</view>
</template>

<script>
	import {
		BASE
	} from '@/const/base.js'
	export default {
		data() {
			return {
				list: [{
					name: '绑定手机号',
					value: '',
					url: '/pages/person/pages/phone_number'
				}, {
					name: '登录密码',
					value: '',
					url: '/pages/person/pages/check_phone'
				}, {
					name: '交易密码',
					value: '',
					url: '/pages/person/pages/pay_password'
				}, {
					name: '用户协议',
					value: '',
					url: '/pages/common/pages/richtext?key=consumer_agreement'
				}, {
					name: '隐私政策',
					value: '',
					url: '/pages/common/pages/richtext?key=private_agreement'
				}, {
					name: '关于我们',
					value: '',
					url: '/pages/common/pages/richtext?key=about_us'
				}],
				userInfo: this.$storage.getItem('basicUnserInfo') || {},
			}
		},
		onShow() {
			this.userInfo = this.$storage.getItem('basicUnserInfo') || {}
			this.$set(this.list[0], 'value', this.$utils.hideTel(this.userInfo.phone || ''))
		},
		methods: {
			handleClick(item) {
				uni.navigateTo({
					url: item.url
				})
			},
			handleLogout() {
				this.$utils.showModal({
					content: '请确认是否退出登录？'
				}).then(() => {
					const tenantId = uni.getStorageSync("tenantId")
					const platformInfo = uni.getStorageSync("platformInfo")
					this.$storage.clear()
					this.$store.commit('setToken','')
					this.$store.commit('setUserInfo', {})
					this.$store.commit('setUserType', process.env.UNI_APP_TYPE == BASE
						.ADMIN_TYPE ? 3 : 4)
					this.$store.commit('setPlatformInfo', platformInfo)
					uni.setStorageSync("tenantId", tenantId)
					uni.setStorageSync("platformInfo", platformInfo)
					uni.reLaunch({
						url:"/pages/index/user"
					})
					// uni.switchTab({
					// 	url:"/pages/index/user"
					// })
					// uni.reLaunch({
					// 	url: '/pages/account/pages/login'
					// })
				})
			}
		},
	}
</script>

<style lang="scss">
	.setting_container {
		.cell {
			padding-left: 32rpx;
			background: #FFFFFF;
			border-radius: 16rpx;

			.cell_content {
				padding-top: 24rpx;
				padding-bottom: 24rpx;
				padding-right: 32rpx;
				border-bottom: 2rpx solid rgba(0, 0, 0, 0.1);
				@include flex_box(row, no-wrap, space-between, center);
			}
		}
	}
</style>